package message.test;

import lodsve.core.configuration.EnableLodsve;
import lodsve.redis.core.annotations.EnableRedis;
import lodsve.redis.timer.RedisEventHandler;
import lodsve.redis.timer.RedisEventType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * .
 *
 * @author sunhao(sunhao.java@gmail.com)
 * @version V1.0, 16/1/12 下午9:42
 */
@Component

@EnableRedis(name = "timer", timer = "timer")
public class RedisTestHandler implements RedisEventHandler {
    @Autowired
    private TestService testService;

    @Override
    public void handler(Serializable key) {
        System.out.println(getEventType().getType() + "===========" + key);

        try {
            testService.test();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    public Serializable resolveKey(String message) {
        return message;
    }

    @Override
    public RedisEventType getEventType() {
        return RedisType.TEST;
    }
}
